/**
 * Project: Maxopta
 * User: Plotnikov Slava
 * Date: 03.07.2008 13:31:48
 *
 * Copyright (c) 1999-2007 Magenta Corporation Ltd. All Rights Reserved.
 * Magenta Technology proprietary and confidential.
 * Use is subject to license terms.
 */
package com.magenta.maxoptra.dto;

import com.magenta.maxoptra.utils.Point;

public class Bound {
    private double longitude1;
    private double latitude1;
    private double longitude2;
    private double latitude2;

    public Bound(double latitude1, double longitude1, double latitude2, double longitude2) {
        this.longitude1 = longitude1;
        this.latitude1 = latitude1;
        this.longitude2 = longitude2;
        this.latitude2 = latitude2;
    }

    public double getMaxLongitude() {
        return Math.max(longitude1, longitude2);
    }

    public double getMaxLatitude() {
        return Math.max(latitude1, latitude2);
    }

    public double getMinLongitude() {
        return Math.min(longitude1, longitude2);
    }

    public double getMinLatitude() {
        return Math.min(latitude1, latitude2);
    }

    public boolean isInside(Point point) {
        return point.getLatitude() >= getMinLatitude() && point.getLatitude() <= getMaxLatitude() &&
                point.getLongitude() >= getMinLongitude() && point.getLongitude() <= getMaxLongitude();
    }

    public boolean isInside(LatLonPoint point) {
        return point.getLat() >= getMinLatitude() && point.getLat() <= getMaxLatitude() &&
                point.getLon() >= getMinLongitude() && point.getLon() <= getMaxLongitude();
    }
}
